<template>
  <div style="height:100%">
    <div v-show="formOrProgram=='公共表单'">
      <!--      <forms ref="forms" @returnFormData="returnFormData"></forms>-->
    </div>
    <div style="height:100%" v-show="formOrProgram=='独立程序'">
      <mainform ref="zdys" @returnFormData="returnFormData" @refreshTableData="refreshTableData" v-if="component!=null" :is="component"></mainform>
    </div>
  </div>
</template>

<script>
//import forms from "./form";
import yjhthtcj from "@/views/jiangjin/jiangjinfpjjfpdjb/view";
import jjfp from "@/views/jiangjin/jiangjinfpjjfpdjb/view";
import jjfpCksp from "@/views/jiangjin/jiangjinfpjjfpdjb/view";
import jjff from "@/views/jiangjin/jiangjinfpjjfpdjb/viewFf1";
import jjffCksp1 from "@/views/jiangjin/jiangjinfpjjfpdjb/viewFf1";
import jjffCksp2 from "@/views/jiangjin/jiangjinfpjjfpdjb/viewFf2";
import fqtb from "@/views/hetongrenwu/hetong/hetongtb/hetongtbfq/index";
import jgtb from "@/views/hetongrenwu/hetong/hetongtb/hetongjgtb/index";
// import htsh from "@/views/hetongrenwu/hetong/hetongqianding/viewhtsh";
// import htwbts from "@/views/hetongrenwu/components/htwbts";
// import ndzb from "@/views/hetongrenwu/hetong/hetongqianding/viewhtsh";

import htcj from "@/views/workflow/business/htlb";
import ndzb from "@/views/workflow/business/zbnd";
import qrzb from "@/views/workflow/business/zbsh";
import htsh from "@/views/workflow/business/zbsh";
import hz from "@/views/workflow/business/cjht";
import fqqd from "@/views/workflow/business/cjht";
import sd from "@/views/workflow/business/wbsh";
import xghtwb from "@/views/workflow/business/wbsh";

import wczqr from "@/views/workflow/business/tbsh";
import wczsh from "@/views/workflow/business/tbsh";

import tbhz from "@/views/hetongrenwu/hetong/hetongtb/hetongjghz/index";
import qtjc from "@/views/hetongrenwu/hetong/hetongtb/hetongqtjc/index";
export default {
  components: {
    // forms,
    yjhthtcj,
    jjfp,
    jjfpCksp,
    jjff,
    jjffCksp1,
    jjffCksp2,
    htsh,
    // htwbts,
    ndzb,
    htcj,
    qrzb,
    hz,
    fqqd,
    sd,
    xghtwb,
    wczqr,
    wczsh,
    fqtb,
    tbhz,
    qtjc,
    jgtb
  },
  data() {
    return {
      components: {
        yjhthtcj,
        jjfp,
        jjfpCksp,
        jjff,
        jjffCksp1,
        jjffCksp2,
        htsh,
        // htwbts,
        ndzb,
        htcj,
        qrzb,
        hz,
        fqqd,
        sd,
        xghtwb,
        wczqr,
        wczsh,
        fqtb,
        tbhz,
        qtjc,
        jgtb
      },
      component: null,
      GUID: "",
      formOrProgram: "",
      formInfo: [],
      formInfoDetailed: [],
      programInterface: "",
      formData: {},
    };
  },
  created: function () {
  },
  methods: {
    init(
      formOrProgram,
      formInfo,
      formInfoDetailed,
      programInterface,
      formData,
      GUID,
      wfYwMain,
      wfYwStream,
      dqYwStream,
      dqTask
    ) {
      // this.$nextTick(() => {
      //   //加的测试代码
      //    //console.log("programInterface = "+ programInterface)
      //    //console.log("wfYwMain.ywLyid = "+ wfYwMain.ywLyid)
      //   /*if(programInterface==='yjhthtsh'&&wfYwMain.ywLyid===247){
      //     wfYwMain.ywLyid　=　247
      //   }*/
      //   this.$refs.zdys.init( wfYwMain.ywLyid)
      // })
      this.formOrProgram = formOrProgram;
     //console.log(formOrProgram)
      if (formOrProgram == "独立程序") {
        this.programInterface = programInterface;
       //console.log(programInterface)
        this.component = this.components[programInterface];
       //console.log('this.component',this.component)
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.GUID = GUID;
            this.formInfo = formInfo;
            this.formInfoDetailed = formInfoDetailed;
            this.formData = formData;
            this.$nextTick(() => {
              this.$nextTick(() => {
                this.$refs.zdys.init(
                  formInfo,
                  formInfoDetailed,
                  formData,
                  GUID,
                  wfYwMain,
                  wfYwStream,
                  dqYwStream,
                  dqTask
                );
              });
            });
          });
        });
      } else {
        this.programInterface = "";
        this.formOrProgram = formOrProgram;
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.GUID = GUID;
            this.formInfo = formInfo;
            this.formInfoDetailed = formInfoDetailed;
            this.formData = formData;
            this.$nextTick(() => {
              this.$nextTick(() => {
                // this.$refs.forms.init(
                //   formInfo,
                //   formInfoDetailed,
                //   formData,
                //   GUID,
                //   wfYwMain,
                //   wfYwStream,
                //   dqYwStream,
                //   dqTask
                // );
              });
            });
          });
        });
      }
    },
    getFormData() {
      if (this.formOrProgram == "公共表单") {
        this.$refs.forms.save();
      } else {
        this.$refs.zdys.getFormData();
      }
    },
    returnFormData(data) {
     //console.log(data)
      this.$emit("returnFormData", data);
    },
    //刷新页面数据
    refreshTableData(data){
      this.$emit("refreshTableData", data);
    }
  },
};
</script>

<style>
</style>
